package games.ThunderFighter;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * Created by Administrator on 2016/12/13.
 */
public class GameWindow extends JFrame implements ActionListener {                               //implements ActionListener,KeyListener

    Icon background=new ImageIcon("F:\\jk\\jk.png");
    JPanel panel;
    static JLabel label;
    JMenuItem item1;
    JMenuItem item2;
    JMenuItem item3;
    JMenuItem item4;
    JMenuItem item5;


    public GameWindow(String s){
        setLayout(null);
        setBounds(300,150,400,650);
        setVisible(true);
        setTitle(s);
        label=new JLabel("分数:"+0);
        JLabel label2 = new JLabel(background);
        label.setBounds(280,0,70,30);
        label2.setBounds(0, 0, background.getIconWidth(), background.getIconHeight());
        Font font=new Font("jk",Font.BOLD,15);
        label.setFont(font);
        panel=new JPanel();
        panel.setLayout(null);
        add(panel);
        panel.add(label);
        panel.setBackground(Color.ORANGE);
        panel.setBounds(0,0,400,650);
        panel.add(label);

        JMenuBar menubar=new JMenuBar();
        JMenu menu1=new JMenu("游戏");
        JMenu menu2=new JMenu("难度");
        item1=new JMenuItem("小学生难度");
        item2=new JMenuItem("中等难度");
        item3=new JMenuItem("高手难度");
        item4=new JMenuItem("老司机难度");
        item5=new JMenuItem("开始新游戏");
        //item1.addActionListener(this);
       // item2.addActionListener(this);
        //item3.addActionListener(this);
       // item4.addActionListener(this);
        item5.addActionListener(this);
        menu1.add(item5);
        menu2.add(item1);  menu2.add(item2);
        menu2.add(item3);  menu2.add(item4);
        menubar.add(menu1);
        menubar.add(menu2);
        setJMenuBar(menubar);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    public void actionPerformed(ActionEvent e){
        if(e.getSource()==item5){
            RunGame.newGame(this);
        }
    }
}


